import harvester = require('./role/role.harvester');
import temp = require("./role/role.temp");
import builder = require("./role/role.builder");
import carrier = require("./role/role.carrier");
import structRepairer = require("./role/role.struct_repairer");
import wallRepairer = require("./role/role.wall_repairer");
import {refreshRoomIdTable} from "./utils";

function getIds(type) {
  const ids: Array<string> = global.roomCache['W35S27'][type];
  if (ids === undefined)
    return [];
  return ids;
}


export = function creepConfigFunction() {
  refreshRoomIdTable("W35S27");
  let extensionId = getIds(STRUCTURE_EXTENSION);
  let roadId = getIds(STRUCTURE_ROAD);
  let towerId = getIds(STRUCTURE_TOWER);
  let wallId = getIds(STRUCTURE_WALL);
  let rampartId = getIds(STRUCTURE_RAMPART);
  let storageId = getIds(STRUCTURE_STORAGE);
  // 角色名: 角色配置项 记得修改矿的 id
  return {
    harvester1: harvester('5bbcab169099fc012e632c6c', ['5f8bcebf321aa831931c00bc']),
    harvester2: harvester('5bbcab169099fc012e632c6c', ['5f8bcebf321aa831931c00bc']),
    carrier2: carrier("5f8bcebf321aa831931c00bc", ['5f8ad20f59e9df6132ccccf2', ...towerId,...storageId]),
    carrier1: carrier("5f8ad20f59e9df6132ccccf2", extensionId),
    temp1: temp("5bbcab169099fc012e632c6e"),
    builder1: builder("5f8ad20f59e9df6132ccccf2"),
    struct_repairer1: structRepairer("5f8bcebf321aa831931c00bc", ["5f8bcebf321aa831931c00bc", ...roadId]),
    wall_repairer1: wallRepairer(storageId[0], [...wallId, ...rampartId]),
  }
}